package Jump_Servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ToOrderView_Servlet
 */
@WebServlet("/ToOrderView_Servlet")
public class ToOrderView_Servlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ToOrderView_Servlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.setContentType("text/html;charset=utf-8");
		String user = (String) request.getSession().getAttribute("UserName");
		String isLogin = (String) request.getSession().getAttribute("IsLogin");
		String uri[] = request.getHeader("Referer").split("/");
		String msg;
		if(user !=null && isLogin.equals("Y")){
			request.getRequestDispatcher("GoOrder_Servlet").forward(request, response);
		}else{
			msg = "请先登录！";
			request.setAttribute("msg", msg);
			if(uri[uri.length-1].endsWith("Servlet")){
				request.getRequestDispatcher("AllGoods_Servlet").forward(request, response);
			}else
				request.getRequestDispatcher(uri[uri.length-1]).forward(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
